﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>驰骋工作流</title>
    <!-- 引用通用的js文件. -->
    <script language="JavaScript" src="/WF/Comm/JS/Calendar/WdatePicker.js" defer="defer"type="text/javascript"></script>
    <link href="../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <link rel="shortcut icon" href="../Img/ccbpm.ico" type="image/x-icon" />
    <script type="text/javascript" src="../Scripts/jquery-1.7.2.min.js"></script>
    <script language="JavaScript" src="../Comm/JScript.js"  type="text/javascript"></script>
    <script type="text/javascript" src="../Scripts/QueryString2016.js"></script>
     <!-- 导入配置文件. -->
    <script type="text/javascript" src="../Scripts/config.js"></script>
    <script type="text/javascript" src="../Comm/Gener.js"></script>

    <script type="text/javascript" language="javascript" >

        var node = null; //公共变量.

        $(function () {
            //   alert(html);
            $("#Msg").html('正在加载，请稍候...');

            var nodeID = GetQueryString("FK_Node");
            var workID = GetQueryString("WorkID");

            node = new Entity("BP.WF.Node", nodeID);

            var gwfs = new Entities("BP.WF.GenerWorkFlows");
            gwfs.Retrieve("FID", workID);

            var html = "<table style='width:100%;' >";
            html+="<caption>子线程信息</caption>";
            html += "<tr>";
            html += "<th>标题</th>";
            html += "<th>停留节点</th>";
            html += "<th>状态</th>";
            html += "<th>处理人</th>";
            html += "<th>发起日期</th>";
            html += "</tr>";

            for (var i = 0; i < gwfs.length; i++) {

                var gwf = gwfs[i];

                html += "<tr class=Sum >";
                html += "<td>" + gwf.Title + "</td>";
                html += "<td>" + gwf.NodeName + "</td>";
                html += "<td>" + gwf.WFStateText + "</td>";
                html += "<td>" + gwf.TodoEmps + "</td>";
                html += "<td>" + gwf.RDT + "</td>";
                html += "</tr>";


                html += "<tr>";
                html += "<td colspan=5 > " + GenerHtml(gwf) + " </td>";
                html += "</tr>";
            }

            $("#Msg").html(html);

        })

        function GenerHtml(gwf) {

            //该子线程下面的 generworkerlist.
            var gwls = new Entities("BP.WF.GenerWorkerLists");
            gwls.Retrieve("WorkID", gwf.WorkID, "IsEnable", 1);

            var strs = "<table style='width:100%;'>";

            strs += "<tr >";
            strs += "<td>序</td>";
            strs += "<td>节点</td>";
            strs += "<td>处理人</td>";
            strs += "<td>名称</td>";
            strs += "<td>状态</td>";
            strs += "<td>应完成日期</td>";
            strs += "<td>实际完成日期</td>";
            strs += "<td></td>";
            strs += "</tr>";

            for (var i = 0; i < gwls.length; i++) {

                var gwl = gwls[i];

                strs += "<tr>";
                strs += "<td>" + i + "</td>";
                strs += "<td>" + gwl.FK_NodeText + "</td>";
                strs += "<td>" + gwl.FK_Emp + "</td>";
                strs += "<td>" + gwl.FK_EmpText + "</td>";

                if (gwl.IsPass == 1) {

                    strs += "<td>已完成</td>";
                    strs += "<td>" + gwl.SDT + "</td>";
                    strs += "<td>" + gwl.RDT + "</td>";

                    if (node.ThreadKillRole == 1)
                        strs += "<td><a href=\"javascript:DoDelSubFlow('" + gwl.FK_Flow + "','" + gwl.WorkID + "')\"><img src='../Img/Btn/Delete.gif' border=0/>终止</a></td>";
                    else
                        strs += "<td>无</td>";

                } else {

                    strs += "<td>未完成</td>";
                    strs += "<td>" + gwl.SDT + "</td>";
                    strs += "<td>无</td>";

                    strs += "<td><a href=\"javascript:OpenFrm('" + gwl.WorkID + "','" + gwl.FID + "','" + gwl.FK_Flow + "','" + GetQueryString("FK_Node") + "')\">打开表单</a>";
                    strs += " - <a href='ReturnWork.htm?WorkID=" + gwl.WorkID + "&FID=" + gwl.FID + "&FK_Flow=" + gwl.FK_Flow + "&FK_Node=" + GetQueryString("FK_Node") + "' >退回</a></td>";
                }
                strs += "<tr>";
            }

            strs += "</table>";
            return strs;
        }

        function OpenFrm(workID, fid, flowNo, nodeID) {

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt_OneWork");
            handler.AddUrlData();

            handler.AddPara("FromWorkOpt", "1");
            handler.AddPara("WorkID", workID);
            handler.AddPara("FK_Node", nodeID);
            handler.AddPara("FK_Flow", flowNo);
            handler.AddPara("FID", fid);

            var data = handler.DoMethodReturnString("Runing_OpenFrm");

            data = data.replace('url@./CCForm', 'url@../CCForm');

            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            if (data.indexOf('url@') == 0) {
                data = data.replace('url@', '');

                if (data.indexOf('FromWorkOpt') == -1)
                    data = data + "&FromWorkOpt=1";

                //alert(data);

                //window.location.href = data;
                window.open(data);
                return;
            }

            alert(data);
        }

        //删除子线城.
        function DoDelSubFlow(flowNo, workID) {

            if (confirm('您缺少要终止该子线程吗？') == false)
                return;

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
            handler.AddPara("FK_Flow", flowNo);
            handler.AddPara("WorkID", workID);

            var data = handler.DoMethodReturnString("ThreadDtl_DelSubFlow");
            window.location.href = window.location.href;
        }

    </script>
</head>
<body>

<form id="cc">

<center><div id="Msg"> <img src='../Img/loading.gif' alt="" />正在加载，请稍后。。。 </div></center>
</form>

</body>
</html>
